package com.zzs.blog.website.util.backup.db;

import java.util.ArrayList;

/**
 * @Author ZechariahZheng
 * @Date 2019/10/27 10:35
 * @Version 1.0
 * @description
 */
public class ColumnCollection extends ArrayList<Column> {

    private static final long serialVersionUID = -3399188477563370223L;

    public int indexByLabel(String label){
        for(int i = 0; i < this.size(); i++){
            if(get(i).getLabel().equals(label)){
                return i;
            }
        }
        return -1;
    }

    @Override
    public String toString() {
        if(size() == 0){
            return "Columns is empty";
        }
        String s = "Columns : {" + String.valueOf(get(0).getLabel());
        for(int i = 1; i < size(); i++){
            s += ", " + String.valueOf(get(i).getLabel());
        }
        s += "}";
        return s;
    }
}
